package com.example.logindb.repository;

import com.example.logindb.entity.Help;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface HelpRepository extends JpaRepository<Help, Integer> {
    List<Help> findAllByBid(int id);

    @Query(
            "SELECT h FROM Help h WHERE h.vid = 0 AND h.lat BETWEEN :minLat AND :maxLat AND h.lon BETWEEN :minLon AND :maxLon"
    )
    List<Help> findBlindMessage(
            Double minLat,
            Double maxLat,
            Double minLon,
            Double maxLon
    );


    Help findAllByAid(Integer aid);

    List<Help> findAllByVid(Integer vid);
}
